//
//  SPNavigationViewController.m
//  ShopProject
//
//  Created by kuangbiao on 2018/11/26.
//  Copyright © 2018 KB. All rights reserved.
//

#import "SPNavigationViewController.h"

@interface SPNavigationViewController ()<UIGestureRecognizerDelegate>

@end

@implementation SPNavigationViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //设置手势代理
    self.interactivePopGestureRecognizer.delegate = self;
    [self setupNavigationBar];
    //去除导航栏下方的横线
//    [self.navigationBar setBackgroundImage:[[UIImage alloc]init]
//                             forBarMetrics:UIBarMetricsDefault];
//    [self.navigationBar setShadowImage:[[UIImage alloc]init]];
    
    //    self.navigationBar.barStyle = UIStatusBarStyleLightContent;
    [self setNeedsStatusBarAppearanceUpdate];
}

- (void)setupNavigationBar
{
    UINavigationBar *appearance = [UINavigationBar appearance];
    appearance.translucent = NO;
    [appearance setBarTintColor:[UIColor colorWithHexString:@"303030"]];
    //导航栏title格式
    NSMutableDictionary *textAttribute = [NSMutableDictionary dictionary];
    textAttribute[NSForegroundColorAttributeName] = [UIColor colorWithHexString:@"ffffff"];
    textAttribute[NSFontAttributeName] =  [UIFont fontWithName:@"PingFangSC-Medium" size:17];
    [appearance setTitleTextAttributes:textAttribute];
}

-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed =YES;
        UIButton *backButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 5, 34, 34)];
        [backButton setImage:[UIImage imageNamed:@"tab_ysj_nav_icon_back"] forState:UIControlStateNormal];
        [backButton setImageEdgeInsets:UIEdgeInsetsMake(0, -10, 0, 0)];
        [backButton addTarget:self action:@selector(popView) forControlEvents:UIControlEventTouchUpInside];
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:backButton];
    }
    [super pushViewController:viewController animated:YES];
}
- (void)popView
{
    [self popViewControllerAnimated:YES];
}


@end
